
-- copy mc area
-- copy mc rel_role_menu
-- copy mc menu

-- init platform data
BEGIN;
INSERT INTO `platform`(id, `description`, `name`,`urlPrefix`,`created`,`type`) VALUES
('002a83d62a304cadbf0cbb156ce28f26', '销售顾问', '麦忒销售系统CRM', 'http://crm.mattbaby.com', '2018-05-18 15:16:53', '2'),
('002a83d62a304cadbf0cbb156ce28f27', '园长/老师', '麦宝管理系统', 'http://t.mattbaby.com', '2018-05-18 15:16:52', '1'),
('002a83d62a304cadbf0cbb156ce28f28', '老板', '麦忒数据经营系统', 'http://data.mattbaby.com', '2018-05-18 15:16:52', '3');
COMMIT;

-- init role data
BEGIN;
INSERT INTO `role`  (id, deleted, description, roleCode, roleName, platformId, created) VALUES
('2c9287856444567501644459db6f0000', b'0', '幼儿园园长', 'ROLE_GARDEN_LEADER', '园长', '002a83d62a304cadbf0cbb156ce28f27', '2018-06-28 11:04:57'),
('2c928785646d5bcf01646d612f030000', b'0', '课程研究员', 'ROLE_RESEARCHER', '研究员', '002a83d62a304cadbf0cbb156ce28f27', '2018-07-06 10:17:23'),
('2c928785646d5bcf01646d62439a0001', b'0', '园区保健医生', 'ROLE_DOCTOR', '园区医生', '002a83d62a304cadbf0cbb156ce28f27', '2018-07-06 10:18:34'),
('2c928785646d5bcf01646d7b383b0006', b'0', '', 'ROLE_BOSS', '老板', '002a83d62a304cadbf0cbb156ce28f28', '2018-07-06 10:45:49'),
('2c92878b63d92d430163d93dfdd30002', b'0', '管理员', 'ROLE_ADMIN', '管理员', '002a83d62a304cadbf0cbb156ce28f27', '2018-06-07 15:55:09'),
('2c92878b63f2c4820163f2c5abf50000', b'0', '老师', 'ROLE_TEACHER', '老师', '002a83d62a304cadbf0cbb156ce28f27', '2018-06-12 14:53:51'),
('4028478d637273c30163727ace570000', b'0', '', 'ROLE_BUSINESS', '销售', '002a83d62a304cadbf0cbb156ce28f26', '2018-05-18 17:02:47');
COMMIT;







ALTER TABLE `materiel_records` ADD COLUMN `operatorName`  VARCHAR(50) NOT NULL COMMENT '操作人姓名' AFTER `operatorId`;
update materiel_records mr , (select s.id as id, s.realName as realName from materiel_records r left join staff s on r.operatorId =s.id ) as n set mr.operatorName = n.realName where mr.operatorId = n.id

-- course_official
ALTER TABLE `course_official` ADD COLUMN `lastModifiedName`  VARCHAR(50) NOT NULL COMMENT '最后修改人名称' AFTER `lastModifiedId`;
update course_official c , (select s.id as id, s.realName as realName from course_official co left join staff s on co.lastModifiedId =s.id ) as n set c.lastModifiedName = n.realName where c.lastModifiedId = n.id

-- children_course_change_record
ALTER TABLE `children_course_change_record` ADD COLUMN `operatorName`  VARCHAR(50) NOT NULL COMMENT '操作人员姓名' AFTER `operatorId`;
update children_course_change_record c , (select s.id as id, s.realName as realName from children_course_change_record co left join staff s on co.operatorId =s.id ) as n set c.operatorName = n.realName where c.operatorId = n.id


-- children_course_change_record
ALTER TABLE `rel_teacher_course_plan_nursery` ADD COLUMN `teacherName`  VARCHAR(50) NOT NULL COMMENT '老师姓名' AFTER `teacherId`;
update rel_teacher_course_plan_nursery c , (select s.id as id, s.realName as realName from rel_teacher_course_plan_nursery co left join staff s on co.teacherId =s.id ) as n set c.teacherName = n.realName where c.teacherId = n.id


ALTER TABLE `user_materiels` ADD COLUMN `uname`  VARCHAR(50) NOT NULL COMMENT '用户名称' AFTER `uid`;
update user_materiels c , (select s.id as id, s.realName as realName from user_materiels co left join staff s on co.uid =s.id ) as n set c.uname = n.realName where c.uid = n.id



DROP TABLE IF EXISTS rel_staff_menu;
DROP TABLE IF EXISTS rel_staff_resources;
DROP TABLE IF EXISTS rel_staff_role;
DROP TABLE IF EXISTS area;

--     - "sso.local"
--     - APITHREE=sso.local

-- 修改dingdingCallBack